package cn.migu.music.hangupsms.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.migu.music.cljz.common.ReturnCode;
import cn.migu.music.hangupsms.common.entity.BillInfo;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
public class SuperUserController {
    @Autowired
    private BaseService            baseService;
    @Autowired
    private ViewVrbtSendMsgService viewVrbtSendMsgService;

    /**
     * 发送挂机短信
     *
     * @param content
     *            话单内容
     * @return 结果
     */
    @GetMapping("/superUser/viewVrbtSmsSend")
    public String viewVrbtSmsSend(@RequestParam("content") String content) {
        BillInfo billInfo = baseService.getBillInfo(content);
        viewVrbtSendMsgService.contentProcess(billInfo);
        return ReturnCode.success.getDesc();
    }

    /**
     * 发送挂机短信
     *
     * @param content
     *            话单内容
     * @param doLimit
     *            是否进行发送时间频率等规则限制
     * @return 结果
     */
    @GetMapping("/superUser/send")
    public String sendHangUpMsg(@RequestParam("content") String content, @RequestParam("doLimit") Boolean doLimit) {
        BillInfo billInfo = baseService.getBillInfo(content);
        if (!doLimit) {
            baseService.contentProcess(billInfo, false);
            return ReturnCode.success.getDesc();
        }
        if (baseService.contentPreProcess(billInfo)) {
            baseService.contentProcess(billInfo, true);
        }
        return "done";
    }
}
